#!/bin/bash
s=10000
e=50

rm ../../log/*
echo > ../../log/start.pids
echo > ../../log/reg.log

if [ $1 ]
then
    rl="start"

    for (( i=$s ; $i < $s + $e ; i=$i+1))
    do
    	rl="$rl|/reg $i $i"
    done
    rl="$rl|stop|/exit"
    perl sock-client1.pl \
	--login admin --pass 12345 \
	--run "$rl" \
    --debug  >../../log/reg.log
fi

c=2
nc=`expr $e / $c`


for (( i=$s ; $i < $s + $e ; i=$i+1))
do
    ch=`expr $i % $nc`
    ch=`expr $ch + $s`
    echo $i ch$ch `date`
    perl sock-client1.pl \
--login $i --pass $i \
--interval 1 --count 1000 --timeout 60 --chanel main \
--response  \
>../../log/$i.log 2>/dev/null &
    echo $! >> ../../log/start.pids
    usleep 10000
done
